var commentUtil ={

    dfsCommentTree:function(eArray,parentId,parentName){
      let responseArrForThisLevel = [];
      if (!eArray)
        return [];
      if (this.isArray(eArray)){
        eArray.forEach(item=>{
          let itemObj={}
          Object.assign(itemObj,{
            id:item.id,
            userId:item.userId,
            userName:item.userName,
            headerImgUrl:item.headerImgUrl,
            clickCount:item.clickCount,
            createTime:item.createTime,
            parentId:parentId,
            parentName:parentName,
            comment:item.comment,
            isCurrUserClick:item.isCurrUserClick,
          })
          responseArrForThisLevel.push(itemObj);
          console.log(this.dfsCommentTree(item.childCommentList,item.id,item.userName),'-----------');
          responseArrForThisLevel = responseArrForThisLevel.concat(this.dfsCommentTree(item.childCommentList,item.id,item.userName))
        })
      }
      return responseArrForThisLevel;
    },
    isArray: function (e) {
      return '[object Array]' === Object.prototype.toString.call(e)
    },

    transToArr:function(commentObj){
        //1.从父节点取到该条评论是顶级或者回复谁的
        //2.将评论树按顶级结构整理成数组，所有对顶级评论的回复都放到数组的response数组中，标明该条回复是@谁的
        //3.sharedSongListId|sharedSongId,clickCount(歌单或歌曲的播放量)与数组处于平级
        /**array结构
         * [{
         *  id,
         *  userid & userName & headerImgUrl,
         *  clickCount(点赞数),
         *  ceateTime,
         *  parentId(0是顶级),
         *  comment(评论内容),
         *  responseArr:[
         *      {},{}
         *  ]
         * }]
         */
        let commentArr = [];
        if (this.isArray(commentObj.childCommentList)){
          commentObj.childCommentList.forEach(item=>{
            let itemObj = {} 
            Object.assign(itemObj,{
              id:item.id,
              userId:item.userId,
              userName:item.userName,
              headerImgUrl:item.headerImgUrl,
              clickCount:item.clickCount,
              createTime:item.createTime,
              parentId:item.parentId,
              parentName:'',
              comment:item.comment,
              isCurrUserClick:item.isCurrUserClick,
              responseArr:[],
            })
            if (this.isArray(item.childCommentList)){
              itemObj.responseArr = this.dfsCommentTree(item.childCommentList,item.id,item.userName)
            }
            commentArr.push(itemObj)
          })
          return commentArr;
        }
        else {
          console.log('commentObj 缺少 childCommentList数组');
        }
        
        
    }
}
commentUtil.transToArr({});

export default commentUtil;